<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><p>
	There are some books, each consisting of exactly three parts: introduction, story and edification. 
	There is a reader who goes through the books and reads various parts. 
	Each time he finishes reading a part, he adds the name of the part to the end of a list. 
	He may read zero or more parts from each book, and he can read them in any order, but he cannot 
	read each part more than once. 
	Whenever he starts reading a new book, he can no longer go back and read any parts of books he has 
	looked at previously.
</p>
<p>
	You are given a vector &lt;string&gt; <b>readParts</b> containing the list created by the reader. 
	Each element of <b>readParts</b> is "introduction", "story" or "edification" (quotes for clarity). 
	Return the maximum possible number of books for which the reader has read all three parts.
</p>
</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td>Class:</td><td>ReadingBooks</td></tr><tr><td>Method:</td><td>countBooks</td></tr><tr><td>Parameters:</td><td>vector &lt;string&gt;</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int countBooks(vector &lt;string&gt; readParts)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>&#160;&#160;&#160;&#160;</td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>readParts</b> will contain between 1 and 50 elements, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>readParts</b> will be "introduction", "story" or "edification" (quotes for clarity).</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;introduction&quot;, &quot;story&quot;, &quot;introduction&quot;, &quot;edification&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2">It is possible that the reader has read the introduction from the first book and all 3 parts from the second one. Of course, it is also possible that he has read one part from four different books, but we are interested in the maximal number of books for which all 3 parts have been read.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;introduction&quot;, &quot;story&quot;, &quot;edification&quot;, &quot;introduction&quot;, &quot;story&quot;, &quot;edification&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 2</pre></td></tr><tr><td><table><tr><td colspan="2">Two books have been read in their entirety.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;introduction&quot;, &quot;story&quot;, &quot;introduction&quot;, &quot;edification&quot;, &quot;story&quot;, &quot;introduction&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;introduction&quot;, &quot;story&quot;, &quot;introduction&quot;, &quot;edification&quot;, &quot;story&quot;,
 &quot;story&quot;, &quot;edification&quot;, &quot;edification&quot;, &quot;edification&quot;, &quot;introduction&quot;,
 &quot;introduction&quot;, &quot;edification&quot;, &quot;story&quot;, &quot;introduction&quot;, &quot;story&quot;,
 &quot;edification&quot;, &quot;edification&quot;, &quot;story&quot;, &quot;introduction&quot;, &quot;edification&quot;,
 &quot;story&quot;, &quot;story&quot;, &quot;edification&quot;, &quot;introduction&quot;, &quot;story&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 5</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc.  Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited.  (c)2003, TopCoder, Inc.  All rights reserved.  </p></body></html>
